<?php

namespace Celaraze\DcatPlus\Forms;

use Dcat\Admin\Widgets\Form;

class WechatPayForm extends Form
{
    /**
     * Handle the form request.
     *
     * @param array $input
     *
     * @return mixed
     */
    public function handle(array $input)
    {
        admin_setting($input);
        return $this
            ->response()
            ->success('配置更新成功！')
            ->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->text('appid', 'Appid')->required()->default(admin_setting('appid'));
        $this->text('mch_id', '微信支付商户号')->required()->default(admin_setting('mch_id'));
        $this->text('key', 'API密钥(key)')->required()->default(admin_setting('key'));
        $this->text('app_secret', 'AppSecret')->required()->default(admin_setting('app_secret'));
    }
}
